<?php
/**
 * egpusersGetAllData.php
 * 
 * (C) 2009, tetsuya.odaka(EzoGP).
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* 
 * EGP_USERSをCSV形式でクライアントにレスポンスする
 * 
 * author；		t.odaka
 * date;		2008/5/26
 * 
*/

	// 前準備
	include("../Myznala/myHeader.inc.php");
	require_once("../Myznala/MyConverter.class.php");
	require_once('../Myznala/MyDBConnection.class.php');
	require_once('EgpusersDao.class.php');
	
	// パラメータをサニタイズして配列に入れる。
	$cObj = new MyConverter();
	$reqParm = $cObj->getRequestParameters();
	
	// コネクションの取得
	$cObj = new MyDBConnection();
	$conn=$cObj->getConnection();

	$dObj=new EgpusersDao();

	if(isset($reqParm['query'])){
		$oArr=$dObj->getAllSortedByEmail($conn,$reqParm['query']);
	}else{
		$oArr=$dObj->getAll($conn);
	}
	
	// connectionのリリース
	$cObj->closeConnection($conn); 

	$data;
	for($i=0;$i<count($oArr);$i++){
		$wObj= $oArr[$i];
		
		$data.=$wObj->getId();
		$data.= ",";
		$data.=$wObj->getEmail();
		$data.= ",";
		$data.=$wObj->getPassword();
		$data.= ",";
		$data.=$wObj->getName();
		$data.= ",";
		$data.=$wObj->getNameYomi();
		$data.= ",";
		$data.=$wObj->getRole();
		$data.= "\n";
	}

	// 出力
	header("Content-Type:text/plain");
	echo($data);
	
	return;
?>